package protocol.SZ_2021;

import java.util.HashMap;

public class Handle2021SZ8C implements IHandle2021SZ {
    @Override
    public String handle(SZ_2021Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x01:
                return handle8C01(cmd);
            default:
                return "深标:未匹配的命令字"+(cmd.readOrder()+","+cmd.readSubOrder());
        }
    }

    private String handle8C01(SZ_2021Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:防伪密标");
        builder.append("\r\n");
        HashMap<Integer,String> list = new HashMap<>();
        list.put(0,"开始显示");
        list.put(1,"停止显示");
        builder.append("显示开关："+list.getOrDefault(cmd.readInt(1),"未定义"));
        builder.append("\r\n");
        builder.append("显示时长(秒)："+cmd.readInt(2));
        builder.append("\r\n");

        builder.append("密标数据区定义："+cmd.readBCD(cmd.leftSize()));
        builder.append("\r\n");

        return builder.toString();
    }
}
